<?php

/**
 * This is the model class for table "{{pro_invoicing}}".
 *
 * The followings are the available columns in table '{{pro_invoicing}}':
 * @property integer $zpi_id
 * @property integer $zp_id
 * @property string $zpi_operator
 * @property integer $zpi_type
 * @property string $zpi_title
 * @property double $zpi_price
 * @property integer $zpi_nums
 * @property integer $zpi_stocks
 * @property string $zpi_content
 * @property integer $inputtime
 */
class ProInvoicing extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return ProInvoicing the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{pro_invoicing}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('zp_id, zpi_type, zpi_nums, zpi_stocks, inputtime', 'numerical', 'integerOnly'=>true),
			array('zpi_price', 'numerical'),
			array('zpi_operator', 'length', 'max'=>50),
			array('zpi_title', 'length', 'max'=>100),
			array('zpi_content', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('zpi_id, zp_id, zpi_operator, zpi_type, zpi_title, zpi_price, zpi_nums, zpi_stocks, zpi_content, inputtime', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'zpi_id' => 'Zpi',
			'zp_id' => 'Zp',
			'zpi_operator' => 'Zpi Operator',
			'zpi_type' => 'Zpi Type',
			'zpi_title' => 'Zpi Title',
			'zpi_price' => 'Zpi Price',
			'zpi_nums' => 'Zpi Nums',
			'zpi_stocks' => 'Zpi Stocks',
			'zpi_content' => 'Zpi Content',
			'inputtime' => 'Inputtime',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('zpi_id',$this->zpi_id);
		$criteria->compare('zp_id',$this->zp_id);
		$criteria->compare('zpi_operator',$this->zpi_operator,true);
		$criteria->compare('zpi_type',$this->zpi_type);
		$criteria->compare('zpi_title',$this->zpi_title,true);
		$criteria->compare('zpi_price',$this->zpi_price);
		$criteria->compare('zpi_nums',$this->zpi_nums);
		$criteria->compare('zpi_stocks',$this->zpi_stocks);
		$criteria->compare('zpi_content',$this->zpi_content,true);
		$criteria->compare('inputtime',$this->inputtime);

		$criteria->order = " inputtime DESC ";//默认为时间倒序
		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}